﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaiser.Models.InputModels;
using Kaiser.Repositories;

namespace Kaiser.Services.Impl
{
    public class PermissionService : IPermissionService
    {
        private readonly IRepository _repository;

        public PermissionService(IRepository repository)
        {
            _repository = repository;//
        }

        public Models.Permission GetItem(Guid permissionId)
        {
            try
            {
                return _repository.GetPermissionItem(permissionId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public Models.Permission GetItem(string permissionName)
        {
            try
            {
                return _repository.GetPermissionItem(permissionName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public List<Models.Permission> GetList()
        {
            try
            {
                return _repository.GetPermissionList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public  void Save(PermissionInput permissionInput)
        {
            try
            {
                  _repository.Save(permissionInput);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public  void Save(IEnumerable<PermissionInput> permissions)
        {
            try
            {
                  _repository.Save(permissions);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public bool Remove(Guid permissionId)
        {
            try
            {
                return _repository.Remove(permissionId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public bool Remove(IEnumerable<Guid> iDs)
        {
            try
            {
                return _repository.Remove(iDs);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
